package com.app.service;

import java.util.List;
import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import com.app.entity.Tests;
import com.app.mapper.TestsDAO;

@Service
public class TestsServiceImpl implements TestsService {
    @Resource
    TestsDAO testsDao;

    public List<Tests> getTestsPager(@Param("skip") int skip, @Param("size") int size) {
        return testsDao.getTestsPager(skip, size);
    }

    public Tests getTestsById(int id) {
        return testsDao.getTestsById(id);
    }

    public int getTestsCount() {
        return testsDao.getTestsCount();
    }

    public int insert(Tests entity) {
        return testsDao.insert(entity);
    }

    public int delete(int id) {
        return testsDao.delete(id);
    }

    public int update(Tests entity) {
        return testsDao.update(entity);
    }

    public List<Tests> getAllTests() {
        return testsDao.getAllTests();
    }


    public List<Tests> getTests(String token) {
        return testsDao.getTests(token);
    }


    public List<Tests> getToken(String token) {
        return testsDao.getToken(token);
    }

    /**
     * 限制打卡次数
     * @param uid
     */
    @Override
    public boolean checkClockIn(String uid) {
        List<Tests> tests = testsDao.checkClockIn(uid);
        if(tests.size() < 2) {
            return true;
        }
        return false;
    }
}
